$(function () {
    // 粒子线条背景
    $(document).ready(function () {
        $('.layui-container').particleground({
            dotColor: '#7ec7fd',
            lineColor: '#7ec7fd'
        })
    })


    let layer;
    layui.use('layer', function () {
        layer = layui.layer;


        // 登录操作

        $('form').on('submit', function (e) {
            e.preventDefault()
            let data = $(this).serialize()

            $.ajax({
                url: '/api/login',
                type: 'POST',
                data: data,
                success: function (res) {
                    layer.msg(res.message);
                    if (res.status == 0) {
                        location.href = "/index.html"
                        localStorage.setItem('mytoken', res.token)
                    }
                }
            })
        })

    });

})